package com.grupo6.domino;

//import java.awt.Color;
//import java.awt.Graphics;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RadialGradientPaint;
import java.awt.TexturePaint;
import java.awt.geom.Rectangle2D;
import java.awt.image.BufferedImage;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

public class VistaTablero extends JPanel {
	private static final long serialVersionUID = 1L;
	private TexturePaint tp;

	public VistaTablero() {
		// custom positioning
		this.setLayout( null );
		//System.out.println(this.getHeight());
		//java.io.File textureFile = new java.io.File( getClass().getResource("/resources/redwood.jpg") );
		try {
			BufferedImage texture = ImageIO.read( getClass().getResource("/com/grupo6/resources/woodtable.jpg") );
			Rectangle2D tr = new Rectangle2D.Double( 0, 0, texture.getWidth(), texture.getHeight() );
			tp = new TexturePaint( texture, tr );
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	
	@Override
	protected void paintComponent(Graphics g)
    {
    	super.paintComponent(g);
    	Graphics2D g2D = (Graphics2D) g;
    	RadialGradientPaint gp = new RadialGradientPaint( getWidth() / 2, getHeight() / 2, 
    													  getHeight() / 2, new float[] {0.0f, 0.7f}, 
    													  new Color[] {Color.DARK_GRAY, Color.BLACK} );
    	if ( tp == null ) {
    		g2D.setPaint( gp );
    	} else {
    		g2D.setPaint( tp );
    	}
    	g2D.fillRect( 0, 0, this.getWidth(), this.getHeight() );
    }
}
